namespace CSharpPro._10._9;

public class Demo
{


    public void TestPrint()
    {
        int num = 10;
        for (int i = 0; i < num; i++)
        {
            if (i == 6)
            {
                break;
            }
            Console.WriteLine(i+"\t");
        }
    }

    public void TestPrint2()
    {
        Console.WriteLine("1000以内水仙花数有；");
        for (int num = 0; num < 1000; num++)
        {
            int hundreds = num / 100;
            int tens = (num / 10) % 10;
            int ones = num % 10;
            if (num == hundreds * hundreds * hundreds + tens * tens * tens + ones * ones * ones)
            {
                Console.WriteLine(num);
            }
        }
    }

    public void TestPrint3()
    {
        Console.WriteLine("100以内的质数有：");
        for (int num = 2; num < 100; num++)
        {
            bool isPrime = true;  
         
            for (int i = 2; i <= Math.Sqrt(num); i++)
            {
                if (num % i == 0)  
                {
                    isPrime = false;
                    break;  
                }
            }
            
            if (isPrime)
            {
                Console.Write(num + " ");
            }
        }
        Console.WriteLine(); 
    }
}